package com.bite.product.controller;


import com.bite.product.api.ProductInterface;
import com.bite.product.mapper.ProductMapper;
import com.bite.product.model.ProductInfo;
import com.bite.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.interfaces.RSAKey;

@RequestMapping("/product")
@RestController
@Slf4j
public class ProductController implements ProductInterface {
    @Autowired
    private ProductService productService;

    @RequestMapping("/{productId}")
    public ProductInfo selectById(@PathVariable("productId") Integer productId) {
        log.info("获取产品 productId: {}", productId);
        return productService.selectById(productId);
    }

    @RequestMapping("/simple")
    public String simple(Integer id) {
        return "product-service simple 接收参数 id: " + id;
    }
    @RequestMapping("/multiple")
    public String multiple(Integer id, String name) {
        return "product-service multiple 接收参数 id: " + id + ", name: " + name;
    }
    @RequestMapping("/object")
    public String object(ProductInfo productInfo) {
        return "product-service object 接收参数 productInfo: " + productInfo.toString();
    }
    @RequestMapping("/json")
    public String json(@RequestBody ProductInfo productInfo) {
        return "product-service json 接收参数 productInfo: " + productInfo.toString();
    }
}
